/*
 * Copyright (c) 2025 Li Auto Inc. and its affiliates
 * Licensed under the Apache License, Version 2.0(the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef SIM_PORT_ADAPT_H
#define SIM_PORT_ADAPT_H

#include <stdint.h>

#define OS_NUTTX

#ifdef OS_NUTTX
#include <nuttx/config.h>
#define OS_CORE_CNT CONFIG_BMP_NCPUS
#endif

typedef enum {
    SIM_PORT_SUCCESS = 0,
    SIM_PORT_ERROR
} sim_port_err_t;

typedef void *sim_port_sem_t;
sim_port_err_t sim_port_sem_init(sim_port_sem_t *sem, uint32_t init_count);
sim_port_err_t sim_port_sem_wait(sim_port_sem_t sem);
sim_port_err_t sim_port_sem_post(sim_port_sem_t sem);
sim_port_err_t sim_port_sem_destroy(sim_port_sem_t sem);

typedef void *sim_port_mutex_t;
sim_port_err_t sim_port_mutex_init(sim_port_mutex_t *mutex);
sim_port_err_t sim_port_mutex_lock(sim_port_mutex_t mutex);
sim_port_err_t sim_port_mutex_unlock(sim_port_mutex_t mutex);
sim_port_err_t sim_port_mutex_destroy(sim_port_mutex_t mutex);

#endif /* SIM_PORT_ADAPT_H */
